package cn.fsd.nacos;

import cn.fsd.domain.Transfer;
import cn.fsd.vo.ResultBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import static cn.fsd.util.FeignConstant.DispatchServiceUrl;

@Component
@FeignClient(value = "dispatch-server",url = DispatchServiceUrl)
public interface DispatchServer {

    /**
     * 调用调度中心微服务接口，根据订单地址规划获得配送中心库房id
     * @param receiver_address 订单配送地址
     * @return 中心库房id
     */
    @GetMapping("/transfer/getStoreroom/{receiver_address}")
    ResultBean<String> getStoreroom(@PathVariable("receiver_address") String receiver_address);

    @GetMapping("/transfer/getByOrderId/{order_id}")
    @ApiOperation(value = "（CustomerService调用）根据order_id查询调拨单，从而得到中心库房id")
    Transfer findByOrderId(@PathVariable("order_id") String order_id);


    /**
     * 根据订单号进行当前订单的调度，生成调拨单和任务单<br/>
     *
     */
    @PostMapping("/order/transferById/{order_id}")
    @ApiOperation(value = "新建订单的实时调度,根据订单号进行当前订单的调度")
    ResultBean transferById(@PathVariable("order_id") String order_id);

    @GetMapping("/task/{order_id}")
    @ApiOperation(value = "(orderService调用)根据订单id得到任务单id")
    String getTaskIdByOrderId(@PathVariable("order_id") String order_id);
}
